package com.demo.springboot.controller;

import com.demo.springboot.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private UserDao userDao;

    @GetMapping("/user/home")
    public String home() {
        System.out.println("/user/home url is invoke...");
        return "user-home";
    }

    @GetMapping("/user/show")
    public String show(@RequestParam("name") String name) {
        System.out.println("/user/show url is invoke...,name=" + name);
        userDao.addUser(name);
        return "user-show-name=" + name;
    }
}
